// TelnetLayer.h: interface for the CTelnetLayer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TELNETLAYER_H__DC0D6EBB_53AC_4213_A8CA_C43F1297C095__INCLUDED_)
#define AFX_TELNETLAYER_H__DC0D6EBB_53AC_4213_A8CA_C43F1297C095__INCLUDED_

#include "SocketLayer.h"
#include "SocketLayerEvents.h"
#include "TelnetLayerEvents.h"
#include "TelnetCommandInterpreter.h"
#include "TelnetOptionCollection.h"
#include "TelnetOptionEvents.h"
#include "ITelnetOptionCollection.h"
#include "ICharStreamFilter.h"
#include "ITelnetDataSender.h"
#include "TelnetLogger.h"
#include "IVirtualKeyboard.h"
#include "IVirtualKeyboardEvents.h"
#include "SocketDataSinkWnd.h"
#include "ITerminalKeyMap.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CTelnetLayer : public CSocketLayerEvents, public ITelnetDataSender, public IVirtualKeyboardEvents
{
private:
	CSocketLayer m_socketLayer;
	CTelnetLayerEvents *m_pEvents;
	CTelnetCommandInterpreter m_cmdip;
	CTelnetOptionCollection m_optionCol;
	friend class CTelnetOptionCollection;

	ICharStreamFilter *m_pCharStreamFilter;
	CTelnetLogger *m_pTelnetLogger;
	ITerminalKeyMap *m_pKeyMap;

// 	static UINT ReadThreadProc(LPVOID pObj);
// 	void ReadThread();

// 	CSocketDataSinkWnd m_socketDataSinkWnd;
// 	friend class CSocketDataSinkWnd;

public:
	void SendOptionCommand(char optionType, char action);
	void SendOptionParameters(char optionType, const CArray<char, char> &parameters);

public:
	virtual void OnSocketChar(char c);
	virtual void OnSocketClosed();
	virtual void OnKeyPress(char c);
	virtual void OnKeyDown(WORD key, BYTE fVirt);

public:
	void RegisterEvents(CTelnetLayerEvents *pEvents);
	BOOL IsConnected();
	void Connect(const CString& host, int port = 23);
	void Disconnect();
	void SetCharStreamFilter(ICharStreamFilter *pCharStreamFilter);
	void SetTelnetLogger(CTelnetLogger *pTelnetLogger);
	void SetKeyMap(ITerminalKeyMap *pKeyMap);

public:

	CTelnetLayer();
	virtual ~CTelnetLayer();

};

#endif // !defined(AFX_TELNETLAYER_H__DC0D6EBB_53AC_4213_A8CA_C43F1297C095__INCLUDED_)
